package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.GetUserIdByUsernameDao;
import dao.MessageDao;
import dao.impl.GetUserIdByUsernameDaoImpl;
import dao.impl.MessageDaoImpl;
import entity.Product_Comment;
import entity.User_Inf;


public class Product_CommentServlet2 extends HttpServlet {
	private GetUserIdByUsernameDao gu = new GetUserIdByUsernameDaoImpl();
	MessageDao ad = new MessageDaoImpl();

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String product_id = request.getParameter("product_id");//商品id
		String username = request.getParameter("username");//用户
		String user_id = request.getParameter("user_id");//用户
		String theme = request.getParameter("theme");
		String content = request.getParameter("context");//评论内容
		String perfume = request.getParameter("perfume");//商品
		String model = request.getParameter("model");//型号Title
		String color = request.getParameter("color");//不要颜色
		PrintWriter out = response.getWriter();
		/* out.print(content+"/n"+perfume+"/n"+ model +"/n"+color); */
//		System.out.println(username + "\t" + content + "\t" + perfume + "\t" + model + "\t	" + color);
		System.out.println(theme);
		System.out.println(content);
		User_Inf user_Inf = gu.getUserIdByUsername(username);
		Product_Comment pc = new Product_Comment();
		pc.setComment_id(null);
		pc.setProduct_id(3);
		pc.setOrder_id(10);
		pc.setUser_id(5);
		pc.setTitle("dfgdfg");
		pc.setContent(content);
		pc.setAudit_status(1);
		pc.setAudit_time(new Date());
		pc.setModified_time(new Date());
		pc.setModel_id(5);
		MessageDao ad = new MessageDaoImpl();
		ad.getMessage(pc);	
		System.out.println(user_Inf.getUserId());
		
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
